﻿package mortal.game.view.lotteryDraw
{
    import Message.Public.*;
    import __AS3__.vec.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.controls.*;
    import fl.data.*;
    import flash.text.*;
    import flash.utils.*;
    import mortal.common.global.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;

    public class lotteryDrawRecodeCellRender extends GCellRenderer
    {
        private var _preTxt:GTextFiled;
        private var _cutLine:ScaleBitmap;
        private var _rewardItemTxtList:GTileList;
        private var _rewardDataList:Vector.<lotteryDrawRecordRewardItemDataGroup>;
        private var _recordType:int;

        public function lotteryDrawRecodeCellRender()
        {
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            var _loc_8:Object = null;
            var _loc_9:lotteryDrawRecordRewardItemDataGroup = null;
            var _loc_10:Object = null;
            var _loc_11:lotteryDrawRecordRewardItemDataGroup = null;
            super.data = param1;
            var _loc_2:* = param1["recordInfo"] as SLotteryRecord;
            this._recordType = int(param1["recordType"]);
            var _loc_3:String = "";
            var _loc_4:* = new Array();
            var _loc_5:int = 0;
            var _loc_6:* = _loc_2.lotteryItems;
            var _loc_7:* = _loc_2.lotteryGold;
            this._rewardDataList = new Vector.<lotteryDrawRecordRewardItemDataGroup>;
            for (_loc_8 in _loc_6)
            {
                
                _loc_9 = new lotteryDrawRecordRewardItemDataGroup();
                _loc_9.itemCode = int(_loc_8);
                _loc_9.itemAmout = _loc_6[_loc_8];
                _loc_9.money = -1;
                _loc_9.diaPt = -1;
                _loc_9.signType = 1;
                this._rewardDataList.push(_loc_9);
            }
            if (this._recordType == lotteryRecordType.Record_Lottery_Mine || this._recordType == lotteryRecordType.Record_Lottery_BArea)
            {
                for (_loc_10 in _loc_7)
                {
                    
                    _loc_11 = new lotteryDrawRecordRewardItemDataGroup();
                    _loc_11.itemCode = -1;
                    _loc_11.itemAmout = -1;
                    _loc_11.diaPt = int(_loc_10);
                    _loc_11.money = int(_loc_7[_loc_10]);
                    _loc_11.signType = 1;
                    this._rewardDataList.push(_loc_11);
                }
            }
            if (this._rewardDataList.length != 0)
            {
                this._rewardDataList[(this._rewardDataList.length - 1)].signType = 0;
            }
            if (this._recordType == lotteryRecordType.Record_Lottery_Mine)
            {
                this._preTxt.text = Language.getString(90442);
            }
            else if (this._recordType == lotteryRecordType.Record_Lottery_BArea)
            {
                this._preTxt.htmlText = Language.getStringByParam(90443, lotteryDrawUtil.getRoleProxyName(_loc_2.entityId), _loc_2.playerName);
            }
            else if (this._recordType == lotteryRecordType.Record_Exchange_Mine)
            {
                this._preTxt.text = Language.getString(90444);
            }
            else if (this._recordType == lotteryRecordType.Record_Exchange_BArea)
            {
                this._preTxt.htmlText = Language.getStringByParam(90445, lotteryDrawUtil.getRoleProxyName(_loc_2.entityId), _loc_2.playerName);
            }
            this.setRewardItemListDataProvider();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._label = "";
            this._preTxt = UIFactory.gTextField("", 0, 0, 500, 20, this);
            this._preTxt.autoSize = TextFieldAutoSize.LEFT;
            this._preTxt.setTextFormat(GlobalStyle.textFormatBai);
            this._cutLine = UIFactory.bg(0, 0, 250, 2, this, ImagesConst.SplitLine);
            this._rewardItemTxtList = UIFactory.tileList(0, 0, 248, 80, this);
            this._rewardItemTxtList.rowHeight = 20;
            this._rewardItemTxtList.columnWidth = 124;
            this._rewardItemTxtList.horizontalGap = 0;
            this._rewardItemTxtList.verticalGap = 0;
            this._rewardItemTxtList.columnCount = 2;
            this._rewardItemTxtList.rowCount = 10;
            this._rewardItemTxtList.setStyle("cellRenderer", lotteryDrawRecordRewardItemCellRender);
            this._rewardItemTxtList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._rewardItemTxtList.direction = ScrollBarDirection.HORIZONTAL;
            return;
        }// end function

        private function setRewardItemListDataProvider() : void
        {
            var _loc_3:int = 0;
            if (!this._rewardDataList)
            {
                return;
            }
            var _loc_1:* = new DataProvider();
            var _loc_2:int = 0;
            while (_loc_2 < this._rewardDataList.length)
            {
                
                _loc_1.addItem(this._rewardDataList[_loc_2]);
                _loc_2++;
            }
            this._rewardItemTxtList.dataProvider = _loc_1;
            this._rewardItemTxtList.drawNow();
            _loc_3 = Math.ceil(this._rewardDataList.length / 2);
            this._rewardItemTxtList.height = _loc_3 * 20;
            this._rewardItemTxtList.y = 20;
            this._cutLine.y = _loc_3 * 20 + 22;
            height = _loc_3 * 20 + 24;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._preTxt.dispose(param1);
            this._preTxt = null;
            this._cutLine.dispose(param1);
            this._cutLine = null;
            this._rewardItemTxtList.dispose(param1);
            this._rewardItemTxtList = null;
            super.disposeImpl(param1);
            return;
        }// end function

    }
}
